<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="cc.bluemc.modules.adminUser.entity.PermissionType"%>
<%@ include file="/WEB-INF/views/commons/taglibs.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  	<title>新建功能</title>
  </head>
  <body>
  <div class="col-md-3">
	  <ul id="permisstionTree" class="ztree"></ul>
  </div>
  <div class="col-md-9">
  	<form action="${ctx}/admin/permission/save" method="post" class="form-horizontal" role="form" id="form">
  		<div class="form-group  form-inline">
		    <label class="col-md-2 control-label">父级：</label>
		    <div class="col-md-10">
		      <input name="pid"  class="form-control" type="hidden"  id="pid" value="${bean.pid}"/>
		      <input readonly="readonly" class="form-control" id="pName" value="${bean.permi.name }"/>
		      <button type="button" class="btn btn-primary" onclick="stickied()">置顶</button>
		    </div>
	  	</div>
 		<div class="form-group  form-inline">
		    <label class="col-md-2 control-label">功能名：</label>
		    <div class="col-md-10">
		    <input type="hidden" value="${bean.id}" name="id"/>
		      <input name="name" class="form-control" value="${bean.name}"
		       datatype="s2-12" placeholder="请输入角色名"/>
		    </div>
	  	</div>
 		<div class="form-group  form-inline">
		    <label class="col-md-2 control-label">code：</label>
		    <div class="col-md-10">
		      <input name="code" class="form-control" value="${bean.code}"
		       datatype="*" placeholder="请输入code"/>
		    </div>
	  	</div>
	  	<div class="form-group  form-inline">
		    <label class="col-md-2 control-label">描述：</label>
		    <div class="col-md-10">
		      <input name="description" class="form-control" value="${bean.description}"
		       placeholder="请输入描述"/>
		    </div>
	  	</div>
	  	<div class="form-group  form-inline">
		    <label class="col-md-2 control-label">类型：</label>
		    <div class="col-md-10">
		    <select name="type" class="form-control" datatype="*">
			   <c:forEach items="<%=PermissionType.values() %>" var="type">
			    <option value="${type}" <c:if test="${type==bean.type }">selected="selected"</c:if>>${type}</option>
			   </c:forEach>
		    </select>
		    </div>
	  	</div>
	  	<div class="form-group  form-inline">
		    <label class="col-md-2 control-label">访问地址：</label>
		    <div class="col-md-10">
		      <input name="url" class="form-control" value="${bean.url}"
		       placeholder="请输入访问地址"/>
		    </div>
	  	</div>
	  	<div class="form-group">
	   	<div class="col-md-5 text-right">
	  		<input type="submit" class="btn btn-primary" value="保存"></input>
	  	</div>
	  </div>
 	</form>
  </div>
  <link rel="stylesheet" href="${ctx}/static/js/zTree_v3/css/demo.css" type="text/css"/>
  <link rel="stylesheet" href="${ctx}/static/js/zTree_v3/css/zTreeStyle/zTreeStyle.css" type="text/css"/>
  <script type="text/javascript" src="${ctx}/static/js/zTree_v3/js/jquery.ztree.all-3.5.min.js"></script>
   	<script type="text/javascript">
   	var setting = {
   		   	view:{selectedMulti:false},
   		 callback:{
   		   	onClick:function(event,treeId,treeNode){
   	   		   	if(treeNode.id!='${bean.id}'){
		   	   		   	$("#pName").val(treeNode.name);
		   	   			$("#pid").val(treeNode.id);
   	   	   		   	}
   	   		   	}
      	   		 },
			data: {
				simpleData: {
   					pIdKey:"pid",
					enable: true
				}
			}
		};
	function stickied(){
		$("#pName").val("");
  		$("#pid").val("");
	}
 	$(function(){
 	 var permTree=$.fn.zTree.init($("#permisstionTree"), setting,eval('${permissionTree}'));
		$("#form").Validform({
			tiptype:4
			})
		});
	</script>
  </body>
</html>
